package com.github.data_manage.dao

import com.github.data_manage.domain.po.PersonEducationExperience
import com.github.data_manage.domain.po.PersonInvestmentExperience
import com.github.data_manage.domain.po.Persons
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query

/**
 *@author CHN
 *@since 2024-08-07 22:07
 */
interface PersonInvestmentExperienceDao : BaseDao<PersonInvestmentExperience> {

    fun removeAllByPersonIdEquals(personId: Int)

    @Query("select p from PersonInvestmentExperience p where p.modified = false and p.personId = :personId order by p.id desc")
    fun findAllByPersonIdEquals(personId: Int): List<PersonInvestmentExperience>

    @Modifying
    @Query("update PersonInvestmentExperience set investmentName = :investmentName where investmentId = :investmentId")
    fun updateInvestmentNameByInvestmentId(investmentId: Int,investmentName: String)

    @Modifying
    @Query("update PersonInvestmentExperience set modified = true where personId = :personId")
    fun modifyAllInvestments(personId: Int)
}
